package edu.zut.cs.javaee.manager.student.service.impl;
/**
 * 
 * @author weining
 *
 */
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers;
import org.springframework.data.domain.ExampleMatcher.StringMatcher;
import org.springframework.stereotype.Service;

import edu.zut.cs.javaee.manager.base.service.impl.GenericManagerImpl;
import edu.zut.cs.javaee.manager.student.dao.MonitorDao;
import edu.zut.cs.javaee.manager.student.domain.Monitor;
import edu.zut.cs.javaee.manager.student.domain.Student;
import edu.zut.cs.javaee.manager.student.service.MonitorManager;
@Service(value="monitorManager")
public class MonitorManagerImpl extends GenericManagerImpl<Monitor, Long> implements MonitorManager{

	MonitorDao monitorDao;
	@Autowired
	public void setMonitorDao(MonitorDao monitorDao) {
		this.monitorDao = monitorDao;
	}

	@Override
	public List<Monitor> findByName(String fullname) {
		// TODO Auto-generated method stub
		Monitor queryCourse = new Monitor();
		queryCourse.setName(fullname);
		ExampleMatcher matcher = ExampleMatcher.matching() // 构建对象
				.withStringMatcher(StringMatcher.CONTAINING) // 改变默认字符串匹配方式：模糊查询
				.withMatcher("name", GenericPropertyMatchers.contains()) // 采用“开始匹配”的方式查询
				.withIgnorePaths("dateCreated", "dateModified"); // 忽略属性：是否关注。因为是基本类型，需要忽略掉
		// 创建实例并查询
		Example<Monitor> ex = Example.of(queryCourse, matcher);
		List<Monitor> result = this.monitorDao.findAll(ex);
		return result;
	}

}
